#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include<QGraphicsPixmapItem>
#include<QGraphicsView>
#include<QGraphicsScene>
#include<QList>
#include "character.h"
#include "bullet.h"
#include "enemy.h"
#include "map.h"
#include "victory.h"
#include "defeat.h"
#include "introduction.h"


namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

    //角色移动
    void Charactermove();
    //按键响应
    void keyPressEvent(QKeyEvent* event);
    void keyReleaseEvent(QKeyEvent* event);

    //子弹生成
    void MyBulletShoot();
    //创建敌人
    void CreateEnemy();
    void EnemyDie();
    //角色撞墙判定
    bool AtWall(int t);
    //子弹撞墙消失
    void Bulletdis();
    //角色死亡
    void Gameover();

    int direction=3;//角色移动方向
    //int toward=1;//敌人朝向
    int X,Y;//敌人坐标
    int where[3];//敌人出生点
    int rest=3;//剩余敌人

    void Drawmap();//画地图


private:
    Ui::MainWindow *ui;

    QGraphicsView mGameview;//游戏视图
    QGraphicsScene mScene;//场景
    QGraphicsScene BeginScence;
    //QGraphicsPixmapItem mCharacter;
    QGraphicsPixmapItem mBackground;
    Bullet mBullet;\
    Enemy* em;
    Victory Gamevictory;
    Defeat Gamedefeat;
    Introduction Gameintroduct;

    //Command Gamecommand;
    //Map *map1=new Map();
    character mCharacter;
    //定时器
    QTimer* mCharacterMoveTimer;//角色移动
    QTimer* ShootTimer;//子弹发射
    QTimer* mBulletMoveTimer;//子弹移动
    QTimer* mEnemyCreateTimer;//敌人创建
    QTimer* mEnemyMoveTimer;//敌人移动
    //容器
    QList<int> mKeyList;//按键
    QList<Bullet*> mBulletList;//子弹
    QList<Enemy*> mEnemyList;//敌人
    QList<QGraphicsPixmapItem*> mWallList;//地图
    //敌人
    Chapter1 *map_1=new Chapter1;

};

#endif // MAINWINDOW_H
